home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / BASIC / LIB / EVENTSHELL / EXTENSION / DrawLib (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1996-04-19  |  43KB  |  1,282 lines

  1.  >Module DrawLib
  2.  -----------------------------------------------------------------------
  3.  DrawFile Handling Routines (version 1.07 19-Apr-96)
  4.  This library contains routines that handle the creation and display
  5.  of DrawFiles.
  6.  -----------------------------------------------------------------------
  7.  Public Methods Supported:
  8.    FNshell_DrawLoadFile
  9.    FNshell_DrawGetFileSize
  10.    FNshell_DrawTextCoord
  11.    PROCshell_DrawCreateFile
  12.    PROCshell_DrawOutlineFont
  13.    PROCshell_DrawSetPathWidth
  14.    PROCshell_DrawSetPathColour
  15.    PROCshell_DrawSetPathNoColour
  16.    PROCshell_DrawSetFillColour
  17.    PROCshell_DrawSetNoFillColour
  18.    PROCshell_DrawStartGroup
  19.    PROCshell_DrawEndGroup
  20.    PROCshell_DrawDestroyFile
  21.    PROCshell_DrawSaveFile
  22.    PROCshell_DrawEllipse
  23.    PROCshell_DrawCircle
  24.    PROCshell_DrawBox
  25.    PROCshell_DrawPathStart
  26.    PROCshell_DrawPathDrawTo
  27.    PROCshell_DrawPathEnd
  28.    PROCshell_DrawPathCloseLine
  29.    PROCshell_DrawLine
  30.    PROCshell_DrawSetFont
  31.    PROCshell_DrawInitFont
  32.    PROCshell_DrawSetUnitsMM
  33.    PROCshell_DrawSetUnitsCM
  34.    PROCshell_DrawSetUnitsIN
  35.    PROCshell_DrawSetUnitsOS
  36.    PROCshell_DrawSetUnitsPT
  37.    PROCshell_DrawSetPathPattern
  38.    PROCshell_DrawGetBoundingBox
  39.    PROCshell_DrawRenderFile
  40.    PROCshell_DrawSetJoinStyleNone
  41.    PROCshell_DrawSetJoinStyleRound
  42.    PROCshell_DrawSetJoinStyleBevelled
  43.    PROCshell_DrawSetEndCapNone
  44.    PROCshell_DrawSetEndCapRound
  45.    PROCshell_DrawSetEndCapSquare
  46.    PROCshell_DrawSetEndCapTriangle
  47.    PROCshell_DrawSetStartCapNone
  48.    PROCshell_DrawSetStartCapRound
  49.    PROCshell_DrawSetStartCapSquare
  50.    PROCshell_DrawSetStartCapTriangle
  51.    PROCshell_DrawSetScale
  52.    PROCshell_DrawGetScale
  53.    PROCshell_DrawResizeWindow
  54.    PROCshell_DrawScaleToWindow
  55.    PROCshell_DrawSpriteArea
  56.  Responses to events raised by other modules
  57.  Private Methods Supported:
  58.    FNshell_DrawFontName
  59.    PROCshell_DrawPutString
  60.    PROCshell_DrawPutCoords
  61.    PROCshell_DrawPutWord
  62.    PROCshell_DrawUpdateObjectBBox
  63.    PROCshell_DrawUpdateBounds
  64.    PROCshell_DrawUpdateGroupBounds
  65.    PROCshell_DrawTextSpace
  66.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  67.  Public routines..
  68.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  69. T$*|Start PROCshell_DrawCreateFile
  70. shell_DrawCreateFile(
  71.  buffer%)
  72.  creator$,style_blk%,trans_matrix%
  73.  EvntShell drawfiles in memory have a 60 byte 'pre-header' which keeps
  74.  track of current settings. The 'pre-header' must not be saved to disk
  75.  as the file will not be a valid drawfile!
  76. Z*buffer% = 
  77. shell_HeapBlockFetch(60+24)
  78. [Ibuffer%!00   = -1      :
  79.  Number of current outline font (-1 if none)
  80. \:buffer%!04   = 60      :
  81.  Size of EvntShell pre-header
  82. ]Sbuffer%!08   = 0       :
  83.  File offset to next free address (from start of file)
  84. ^O|(buffer%+12)=1814.1732:
  85.  Current unit multiplier factor (real nr, 5 bytes)
  86. _1buffer%!20   = 7       :
  87.  Current path colour
  88. `1buffer%!24   = -1      :
  89.  Current fill colour
  90. aNbuffer%!28   = 0       :
  91.  File offset to start of current group definition
  92. b0buffer%!32   = 0       :
  93.  Current path width
  94. c-buffer%!36   = 0       :
  95.  Current end cap
  96. dMbuffer%!40   = -1      :
  97.  Number of outline fonts declared   (-1 if none)
  98. eVbuffer%!44   = -1      :
  99.  File offset to start of font table (-1 if no font table)
  100. fEbuffer%!48   = 0       :
  101.  Pointer to path style description block
  102. g,buffer%!52   = 
  103. shell_HeapBlockFetch(24)
  104. hG$(buffer% + (buffer%!04))= "Draw"  :
  105.  Required to tag as a drawfile
  106. i>buffer%!(buffer%!04 + 4) = 201     :
  107.  Major version number
  108. j>buffer%!(buffer%!04 + 8) = 0       :
  109.  Minor version number
  110. kW$(buffer% + (buffer%!04 + 12)) = 
  111. shell_StringPadTrailing(
  112. shell_GetAppName," ",11)
  113. lLbuffer%!08 = buffer%!04 + 24       :
  114.  24 is length of DrawFile so far...
  115.  Set extent words of DrawFile to be 0,0,1,1...
  116. shell_DrawPutWord(0,buffer%)
  117. shell_DrawPutWord(0,buffer%)
  118. shell_DrawPutWord(0,buffer%)
  119. shell_DrawPutWord(0,buffer%)
  120. r*buffer%!48 = 
  121. shell_HeapBlockFetch(16)
  122. style_blk% = buffer%!48
  123. style_blk%!00 = 0
  124. style_blk%!04 = 0
  125. style_blk%!08 = 0
  126. style_blk%!12 = 0
  127. x*buffer%!52 = 
  128. shell_HeapBlockFetch(24)
  129. trans_matrix% = buffer%!52
  130. z)trans_matrix%!00 = 1 << 16 :
  131.  x scale
  132. {*trans_matrix%!04 = 0       :
  133.  rotation
  134. |*trans_matrix%!08 = 0       :
  135.  rotation
  136. })trans_matrix%!12 = 1 << 16 :
  137.  y scale
  138. ~3trans_matrix%!16 = 0       :
  139.  x position offset
  140. 3trans_matrix%!20 = 0       :
  141.  y position offset
  142. "DRW_PATH_START%    = buffer%!8
  143. DRW_PATH_SCALE_FAC = 1
  144. DRW_PATH_XMIN = 0
  145. DRW_PATH_YMIN = 0
  146. DRW_PATH_XMAX = 0
  147. DRW_PATH_YMAX = 0
  148. #*|Stop PROCshell_DrawCreateFile
  149. %*|Start PROCshell_DrawOutlineFont
  150. shell_DrawOutlineFont( 
  151.  buffer%, text$, ptsize, pthigh, xorigin ,yorigin )
  152.  start%,ptr%,lx%,by%,rx%,ty%,font%,scl_fac
  153. scl_fac = |(buffer%+12)
  154. font% = !buffer%
  155.  text$ <> "" 
  156. 3  buffer% = 
  157. shell_HeapBlockExtend(buffer%,256)
  158. #  ptr%    = buffer% + buffer%!8
  159.   start%  = ptr%
  160. /  !ptr%   =   1              :
  161.  Text object
  162. D  ptr%    += 24              :
  163.  Skip size, object bounds for now
  164. #  lx%     = (xorigin * scl_fac)
  165. #  by%     = (yorigin * scl_fac)
  166.  PROCshell_Tracef0("DEBUG::font is "+STR$font%)
  167.  PROCshell_Tracef0("DEBUG::font is "+FNshell_DrawFontName(buffer%,font%))
  168.  "Font_FindFont",,
  169. shell_DrawFontName(buffer%,font%),ptsize * 16, pthigh * 16 
  170.  handle%
  171.  "Font_SetFont",handle%
  172.  "Font_StringBBox",,text$ 
  173.  ,r1%,r2%,r3%,r4%
  174.  "Font_LoseFont",handle%
  175.  PROCshell_Tracef0("DEBUG::r1% = "+STR$r1%)
  176.  PROCshell_Tracef0("DEBUG::r2% = "+STR$r2%)
  177.  PROCshell_Tracef0("DEBUG::r3% = "+STR$r3%)
  178.  PROCshell_Tracef0("DEBUG::r4% = "+STR$r4%)
  179. &  rx%     = lx% + ((r3%/1000)*640)
  180. &  ty%     = by% + ((r4%/1000)*640)
  181.  PROCshell_Tracef0("DEBUG::lx%="+STR$lx%)
  182.  PROCshell_Tracef0("DEBUG::by%="+STR$by%)
  183.  PROCshell_Tracef0("DEBUG::rx%="+STR$rx%)
  184.  PROCshell_Tracef0("DEBUG::ty%="+STR$ty%)
  185. shell_DrawPutCoords(start% + 8,lx%,by%,rx%,ty%)
  186. '  !ptr%   = buffer%!20   :ptr% += 4
  187. '  !ptr%   = buffer%!24   :ptr% += 4
  188. '  !ptr%   = font%        :ptr% += 4
  189. '  !ptr%   = ptsize * 640 :ptr% += 4
  190. '  !ptr%   = pthigh * 640 :ptr% += 4
  191. 1  !ptr%   = xorigin * |(buffer%+12):ptr% += 4
  192. 1  !ptr%   = yorigin * |(buffer%+12):ptr% += 4
  193. shell_DrawPutString(text$,ptr%)
  194.   start%!4 = ptr% - start%
  195. shell_DrawUpdateBounds(buffer%,lx%,by%,rx%,ty%)
  196. >  buffer% = 
  197. shell_HeapBlockExtend(buffer%,start%!4 - 256)
  198.   buffer%!8 += start%!4
  199. $*|Stop PROCshell_DrawOutlineFont
  200. &*|Start PROCshell_DrawSetPathWidth
  201. shell_DrawSetPathWidth(buffer%,width)
  202. 1buffer%!32 = 
  203. ((width * |(buffer%+12)) + 0.5)
  204. %*|Stop PROCshell_DrawSetPathWidth
  205. '*|Start PROCshell_DrawSetPathColour
  206. shell_DrawSetPathColour( buffer%, R%, G%, B% )
  207.  ( ( R% = -1 ) 
  208.  ( G% = -1 ) 
  209.  ( B% = -1 ) )
  210. shell_DrawSetPathNoColour( buffer% )
  211.   buffer%?20 = 0
  212.   buffer%?21 = R%
  213.   buffer%?22 = G%
  214.   buffer%?23 = B%
  215. &*|Stop PROCshell_DrawSetPathColour
  216. )*|Start PROCshell_DrawSetPathNoColour
  217. shell_DrawSetPathNoColour( buffer% )
  218. buffer%!20 = -1
  219. (*|Stop PROCshell_DrawSetPathNoColour
  220. '*|Start PROCshell_DrawSetFillColour
  221. shell_DrawSetFillColour( buffer%, R%, G%, B% )
  222.  ( ( R% = -1 ) 
  223.  ( G% = -1 ) 
  224.  ( B% = -1 ) ) 
  225. shell_DrawSetNoFillColour( buffer% )
  226.   buffer%?24 = 0
  227.   buffer%?25 = R%
  228.   buffer%?26 = G%
  229.   buffer%?27 = B%
  230. &*|Stop PROCshell_DrawSetFillColour
  231. )*|Start PROCshell_DrawSetNoFillColour
  232. shell_DrawSetNoFillColour( buffer% )
  233. buffer%!24 = -1
  234. (*|Stop PROCshell_DrawSetNoFillColour
  235. $*|Start PROCshell_DrawStartGroup
  236. shell_DrawStartGroup(
  237.  buffer%,name$)
  238.  next%
  239.  buffer%!28 > 0 
  240. shell_DrawEndGroup( buffer% )
  241. Kbuffer%!28 = buffer%!08:
  242.  Store file offset to current group definition
  243.  PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
  244. shell_DrawPutWord(06,buffer%) :
  245.  Object type 6 (group)
  246. shell_DrawPutWord(36,buffer%) :
  247.  Current size of group object
  248. shell_DrawPutWord(-1,buffer%) :
  249.  Bounding box xmin
  250. shell_DrawPutWord(-1,buffer%) :
  251.  Bounding box ymin
  252. shell_DrawPutWord(1,buffer%)  :
  253.  Bounding box xmax
  254. shell_DrawPutWord(1,buffer%)  :
  255.  Bounding box ymax
  256. 0buffer% = 
  257. shell_HeapBlockExtend(buffer%,12)
  258. "next%   = buffer% + buffer%!08
  259. $next%  = name$
  260. Abuffer%!08 += 12 :
  261.  Update file offset to next free address..
  262. #*|Stop PROCshell_DrawStartGroup
  263. "*|Start PROCshell_DrawEndGroup
  264. shell_DrawEndGroup( buffer% )
  265.  start%
  266.  buffer%!28 > 0 
  267. %  start% = buffer% + (buffer%!28)
  268. /  start%!4 = (buffer% + buffer%!8) - start%
  269.   buffer%!28 = 0
  270. !*|Stop PROCshell_DrawEndGroup
  271. #%*|Start PROCshell_DrawDestroyFile
  272. shell_DrawDestroyFile( buffer% )
  273. shell_HeapBlockExists(buffer%!48) 
  274. shell_HeapBlockReturn(buffer%!48)
  275. shell_HeapBlockReturn( buffer% )
  276. )$*|Stop PROCshell_DrawDestroyFile
  277. -"*|Start PROCshell_DrawSaveFile
  278. shell_DrawSaveFile(buffer%,file$)
  279.  Add some error trapping here...
  280. X% = 
  281. (file$)
  282.  PROCshell_Tracef0("DEBUG::size is "+STR$(buffer%!8 - buffer%!4))
  283.  "OS_GBPB",2,X%,buffer% + (buffer%!4),buffer%!8 - buffer%!4
  284. ("SetType "+file$+ " &AFF")
  285. 8!*|Stop PROCshell_DrawSaveFile
  286. < *|Start FNshell_DrawLoadFile
  287. shell_DrawLoadFile( name$ )
  288.  buff%, X%, size%
  289. shell_DrawCreateFile( buff% )
  290. @,buff%!8 -= 40 :
  291.  don't need the header..
  292. A$size% = 
  293. shell_FileLength(name$)
  294. B/buff% = 
  295. shell_HeapBlockExtend(buff%,size%)
  296. X% = 
  297. ( name$ )
  298.  "OS_GBPB", 4, X%, buff% + buff%!4, size%
  299. buff%!8 = size% + buff%!4
  300. shell_DrawSetScale( buff%, 1, 1 )
  301. = buff%
  302. *|Stop FNshell_DrawLoadFile
  303. N!*|Start PROCshell_DrawEllipse
  304. shell_DrawEllipse(
  305.  buffer%,X,Y,Xm,Ym)
  306.  start%,A,B,C,D,E,K,Xs,Ys
  307. start% = buffer%!8
  308. X  = X  * |(buffer%+12)
  309. Y  = Y  * |(buffer%+12)
  310. Xm = Xm * |(buffer%+12)
  311. Ym = Ym * |(buffer%+12)
  312.  PROCshell_Tracef0("DEBUG::X="+STR$X)
  313.  PROCshell_Tracef0("DEBUG::Y="+STR$Y)
  314.  PROCshell_Tracef0("DEBUG::Xm="+STR$Xm)
  315.  PROCshell_Tracef0("DEBUG::Ym="+STR$Ym)
  316.  Xm >= Ym 
  317.   A = Xm / Xm / 10 + 0.5
  318.  Xm / Ym < 2 
  319.  A = 0.7
  320.  Xm / Ym > 4.5 
  321.  A = 0.95
  322.   Xs = A * Xm
  323. _(  Ys = 
  324. (1 - Xs * Xs / Xm / Xm) * Ym
  325.  Ym > Xm 
  326.   A = Ym / Xm / 10 + 0.5
  327.  Ym / Xm < 2 
  328.  A = 0.7
  329.  Ym / Xm > 4.5 
  330.  A = 0.95
  331.   Ys = A * Ym
  332. f(  Xs = 
  333. (1 - Ys * Ys / Ym / Ym) * Xm
  334. B = Ym + (Ym - Ys) / 3
  335. i%K = Xs * Xs + (B - Ys) * (B - Ys)
  336. j.C = (
  337. (4 * Xs * Xs + 12 * K) - 2 * Xs) / 6
  338. D = Xm + (Xm - Xs) / 3
  339. l%K = Ys * Ys + (D - Xs) * (D - Xs)
  340. m.E = (
  341. (4 * Ys * Ys + 12 * K) - 2 * Ys) / 6
  342. shell_DrawPutWord(2,buffer%)           :
  343.  Object type 2 (path)
  344. shell_DrawPutWord(0,buffer%)           :
  345.  Size of object (dummy value)
  346. shell_DrawPutWord(X - Xm,buffer%):
  347.  Set size of bounding box xmin
  348. shell_DrawPutWord(Y - Ym,buffer%):
  349.  Set size of bounding box ymin
  350. shell_DrawPutWord(X + Xm,buffer%):
  351.  Set size of bounding box xmax
  352. shell_DrawPutWord(Y + Ym,buffer%):
  353.  Set size of bounding box ymax
  354. shell_DrawUpdateBounds(buffer%,X - Xm,Y - Ym,X + Xm,Y + Ym)
  355. shell_DrawPutWord(buffer%!24,buffer%)  :
  356.  Fill colour
  357. shell_DrawPutWord(buffer%!20,buffer%)  :
  358.  Path colour
  359. shell_DrawPutWord(buffer%!32,buffer%)  :
  360.  Path width
  361. shell_DrawPutWord(00,buffer%)          :
  362.  Pattern
  363. shell_DrawPutWord(2,buffer%)           :
  364.  Absolute move
  365. shell_DrawPutWord(X + Xs,buffer%)      :
  366.  x start
  367. shell_DrawPutWord(Y - Ys,buffer%)      :
  368.  y start
  369. shell_DrawPutWord(6,buffer%)
  370. shell_DrawPutWord(X + C,buffer%)
  371. shell_DrawPutWord(Y - B,buffer%)
  372. shell_DrawPutWord(X - C,buffer%)
  373. shell_DrawPutWord(Y - B,buffer%)
  374. shell_DrawPutWord(X - Xs,buffer%)
  375. shell_DrawPutWord(Y - Ys,buffer%)
  376. shell_DrawPutWord(6,buffer%)
  377. shell_DrawPutWord(X - D,buffer%)
  378. shell_DrawPutWord(Y - E,buffer%)
  379. shell_DrawPutWord(X - D,buffer%)
  380. shell_DrawPutWord(Y + E,buffer%)
  381. shell_DrawPutWord(X - Xs,buffer%)
  382. shell_DrawPutWord(Y + Ys,buffer%)
  383. shell_DrawPutWord(6,buffer%)
  384. shell_DrawPutWord(X - C,buffer%)
  385. shell_DrawPutWord(Y + B,buffer%)
  386. shell_DrawPutWord(X + C,buffer%)
  387. shell_DrawPutWord(Y + B,buffer%)
  388. shell_DrawPutWord(X + Xs,buffer%)
  389. shell_DrawPutWord(Y + Ys,buffer%)
  390. shell_DrawPutWord(6,buffer%)
  391. shell_DrawPutWord(X + D,buffer%)
  392. shell_DrawPutWord(Y + E,buffer%)
  393. shell_DrawPutWord(X + D,buffer%)
  394. shell_DrawPutWord(Y - E,buffer%)
  395. shell_DrawPutWord(X + Xs,buffer%)
  396. shell_DrawPutWord(Y - Ys,buffer%)
  397. shell_DrawPutWord(0,buffer%)               :
  398.  End of path
  399. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  400.  Store size of object
  401.  *|Stop PROCshell_DrawEllipse
  402.  *|Start PROCshell_DrawCircle
  403. shell_DrawCircle(
  404.  buffer%,X,Y,R)
  405.  start%,A,B,C,style_blk%
  406. style_blk% = buffer%!48
  407. start% = buffer%!8
  408. X = X * |(buffer%+12)
  409. Y = Y * |(buffer%+12)
  410. R = R * |(buffer%+12)
  411. A = R / 
  412. B = A + R / 2.544
  413. C = A - R / 2.544
  414. shell_DrawPutWord(2,buffer%)               :
  415.  Object type 2 (path)
  416. shell_DrawPutWord(0,buffer%)               :
  417.  Size of object (dummy value)
  418. shell_DrawPutWord(X - R,buffer%)           :
  419.  Set size of bounding box xmin
  420. shell_DrawPutWord(Y - R,buffer%)           :
  421.  Set size of bounding box ymin
  422. shell_DrawPutWord(X + R,buffer%)           :
  423.  Set size of bounding box xmax
  424. shell_DrawPutWord(Y + R,buffer%)           :
  425.  Set size of bounding box ymax
  426. shell_DrawUpdateBounds(buffer%,X - R,Y - R,X + R,Y + R)
  427. shell_DrawPutWord(buffer%!24,buffer%)      :
  428.  Fill colour
  429. shell_DrawPutWord(buffer%!20,buffer%)      :
  430.  Path colour
  431. shell_DrawPutWord(buffer%!32,buffer%)      :
  432.  Path width
  433. shell_DrawPutWord(style_blk%!0,buffer%)    :
  434.  Style word
  435.  (style_blk%?0 
  436.  1 << 7) <> 0 
  437. shell_DrawPutWord(style_blk%!04,buffer%) :
  438.  Offset to pattern start
  439. shell_DrawPutWord(style_blk%!08,buffer%) :
  440.  Nr of elements in pattern
  441. shell_DrawPutWord(style_blk%!12,buffer%) :
  442.  Length of dash element
  443. shell_DrawPutWord(2,buffer%)               :
  444.  Absolute move
  445. shell_DrawPutWord(X + A,buffer%)           :
  446.  x start
  447. shell_DrawPutWord(Y - A,buffer%)           :
  448.  y start
  449. shell_DrawPutWord(6,buffer%)
  450. shell_DrawPutWord(X + C,buffer%)
  451. shell_DrawPutWord(Y - B,buffer%)
  452. shell_DrawPutWord(X - C,buffer%)
  453. shell_DrawPutWord(Y - B,buffer%)
  454. shell_DrawPutWord(X - A,buffer%)
  455. shell_DrawPutWord(Y - A,buffer%)
  456. shell_DrawPutWord(6,buffer%)
  457. shell_DrawPutWord(X - B,buffer%)
  458. shell_DrawPutWord(Y - C,buffer%)
  459. shell_DrawPutWord(X - B,buffer%)
  460. shell_DrawPutWord(Y + C,buffer%)
  461. shell_DrawPutWord(X - A,buffer%)
  462. shell_DrawPutWord(Y + A,buffer%)
  463. shell_DrawPutWord(6,buffer%)
  464. shell_DrawPutWord(X - C,buffer%)
  465. shell_DrawPutWord(Y + B,buffer%)
  466. shell_DrawPutWord(X + C,buffer%)
  467. shell_DrawPutWord(Y + B,buffer%)
  468. shell_DrawPutWord(X + A,buffer%)
  469. shell_DrawPutWord(Y + A,buffer%)
  470. shell_DrawPutWord(6,buffer%)
  471. shell_DrawPutWord(X + B,buffer%)
  472. shell_DrawPutWord(Y + C,buffer%)
  473. shell_DrawPutWord(X + B,buffer%)
  474. shell_DrawPutWord(Y - C,buffer%)
  475. shell_DrawPutWord(X + A,buffer%)
  476. shell_DrawPutWord(Y - A,buffer%)
  477. shell_DrawPutWord(0,buffer%)               :
  478.  End of path
  479. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  480.  Store size of object
  481. *|Stop PROCshell_DrawCircle
  482. *|Start PROCshell_DrawBox
  483. shell_DrawBox(
  484.  buffer%,x0,y0,width,height)
  485.  start%,scl_fac, style_blk%
  486. start% = buffer%!8
  487. style_blk% = buffer%!48
  488. scl_fac = |(buffer%+12)
  489. x0     = x0     * scl_fac
  490. y0     = y0     * scl_fac
  491. width  = width  * scl_fac
  492. height = height * scl_fac
  493. shell_DrawPutWord(2,buffer%)           :
  494.  Object type 2 (path)
  495. shell_DrawPutWord(0,buffer%)           :
  496.  Size of object (dummy value)
  497. shell_DrawPutWord(x0,buffer%)          :
  498.  Set size of bounding box xmin
  499. shell_DrawPutWord(y0,buffer%)          :
  500.  Set size of bounding box ymin
  501. shell_DrawPutWord(x0 + width,buffer%)  :
  502.  Set size of bounding box xmax
  503. shell_DrawPutWord(y0 + height,buffer%) :
  504.  Set size of bounding box ymax
  505. shell_DrawUpdateBounds(buffer%,x0,y0,x0 + width,y0 + height)
  506. shell_DrawPutWord(buffer%!24,buffer%)  :
  507.  Fill colour
  508. shell_DrawPutWord(buffer%!20,buffer%)  :
  509.  Path colour
  510. shell_DrawPutWord(buffer%!32,buffer%)  :
  511.  Path width
  512. shell_DrawPutWord(style_blk%!0,buffer%):
  513.  Style
  514. shell_DrawPutWord(02,buffer%)          :
  515.  Absolute move
  516. shell_DrawPutWord(x0,buffer%)          :
  517.  x start
  518. shell_DrawPutWord(y0,buffer%)          :
  519.  y start
  520. shell_DrawPutWord(08,buffer%)          :
  521.  Draw to absolute position
  522. shell_DrawPutWord(x0,buffer%)
  523. shell_DrawPutWord(y0 + height,buffer%)
  524. shell_DrawPutWord(08,buffer%)
  525. shell_DrawPutWord(x0 + width,buffer%)
  526. shell_DrawPutWord(y0 + height,buffer%)
  527. shell_DrawPutWord(08,buffer%)
  528. shell_DrawPutWord(x0 + width,buffer%)
  529. shell_DrawPutWord(y0,buffer%)
  530. shell_DrawPutWord(08,buffer%)
  531. shell_DrawPutWord(x0,buffer%)
  532. shell_DrawPutWord(y0,buffer%)
  533. shell_DrawPutWord(00,buffer%)           :
  534.  End of path
  535. G!(buffer% + start% + 4) = buffer%!8 - start%:
  536.  Store size of object
  537. *|Stop PROCshell_DrawBox
  538.  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  539.  Path Object
  540.  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  541. #*|Start PROCshell_DrawPathStart
  542. shell_DrawPathStart( 
  543.  buffer%, x_coord, y_coord )
  544.  style_blk%
  545. style_blk% = buffer%!48
  546.  Set up Module Globals..
  547. !"DRW_PATH_START%    = buffer%!8
  548. "*DRW_PATH_SCALE_FAC = |( buffer% + 12 )
  549. #*x_coord = x_coord * DRW_PATH_SCALE_FAC
  550. $*y_coord = y_coord * DRW_PATH_SCALE_FAC
  551.  DRW_PATH_XMIN = x_coord
  552.  DRW_PATH_YMIN = x_coord
  553.  DRW_PATH_XMAX = y_coord
  554.  DRW_PATH_YMAX = y_coord
  555. DRW_PATH_XMIN = x_coord
  556. DRW_PATH_YMIN = y_coord
  557. DRW_PATH_XMAX = -&7FFFFFFF
  558. DRW_PATH_YMAX = -&7FFFFFFF
  559. shell_DrawPutWord( 2,buffer% )  :
  560.  Object type 2 (path)
  561. shell_DrawPutWord( 0,buffer% )  :
  562.  Size of object (dummy value)
  563. shell_DrawPutWord( DRW_PATH_XMIN, buffer% ) :
  564.  Set size of bounding box xmin
  565. shell_DrawPutWord( DRW_PATH_YMIN, buffer% ) :
  566.  Set size of bounding box ymin
  567. shell_DrawPutWord( DRW_PATH_XMAX, buffer% ) :
  568.  Set size of bounding box xmax
  569. shell_DrawPutWord( DRW_PATH_YMAX, buffer% ) :
  570.  Set size of bounding box ymax
  571. shell_DrawPutWord( buffer%!24, buffer% )   :
  572.  Fill colour
  573. shell_DrawPutWord( buffer%!20, buffer% )   :
  574.  Path colour
  575. shell_DrawPutWord( buffer%!32, buffer% )   :
  576.  Path width
  577. shell_DrawPutWord( style_blk%!0, buffer% ) :
  578.  Style
  579. shell_DrawPutWord( 02,buffer% )          :
  580.  Absolute move
  581. shell_DrawPutWord( x_coord, buffer% )    :
  582.  x start
  583. shell_DrawPutWord( y_coord, buffer% )    :
  584.  y start
  585. <"*|Stop PROCshell_DrawPathStart
  586. @$*|Start PROCshell_DrawPathDrawTo
  587. shell_DrawPathDrawTo( 
  588.  buffer%, x_coord, y_coord )
  589. shell_DrawPutWord( 08, buffer% ) :
  590.  Draw to absolute position
  591. C*x_coord = x_coord * DRW_PATH_SCALE_FAC
  592. D*y_coord = y_coord * DRW_PATH_SCALE_FAC
  593. shell_DrawPutWord( x_coord, buffer% )
  594. shell_DrawPutWord( y_coord, buffer% )
  595. shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
  596. J#*|Stop PROCshell_DrawPathDrawTo
  597. N!*|Start PROCshell_DrawPathEnd
  598. shell_DrawPathEnd( 
  599.  buffer% )
  600. shell_DrawPutWord( 00, buffer% )
  601.  Store size of object..
  602. RD!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
  603. shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
  604. V *|Stop PROCshell_DrawPathEnd
  605. Z'*|Start PROCshell_DrawPathCloseLine
  606. shell_DrawPathCloseLine( 
  607.  buffer% )
  608. shell_DrawPutWord( 05, buffer% )
  609. shell_DrawPutWord( 00, buffer% )
  610.  Store size of object..
  611. _D!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
  612. shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
  613. c&*|Stop PROCshell_DrawPathCloseLine
  614. *|Start PROCshell_DrawLine
  615. shell_DrawLine(
  616.  buffer%,x0,y0,x1,y1)
  617.  start%,pat_blk%,scl_fac,style_blk%,p_width%,cap_width%,cap_len%
  618.  cap_width2%,cap_len2%,bbox_xmin,bbox_xmax,bbbox_ymin,bbox_ymax
  619. scl_fac = |(buffer%+12)
  620. start% = buffer%!8
  621. nHx0 = x0 * scl_fac :
  622.  Convert to draw units using stored scale factor
  623. y0 = y0 * scl_fac
  624. x1 = x1 * scl_fac
  625. y1 = y1 * scl_fac
  626. p_width%   = buffer%!32
  627. style_blk% = buffer%!48
  628.  x0 > x1 
  629.   bbox_xmin = x1
  630.   bbox_xmax = x0
  631.   bbox_xmin = x0
  632.   bbox_xmax = x1
  633.  y0 > y1 
  634.   bbox_ymin = y1
  635.   bbox_ymax = y0
  636.   bbox_ymin = y0
  637.   bbox_ymax = y1
  638.  PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 2)))
  639.  PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 3)))
  640.  (style_blk%?0 
  641.  %1100) 
  642.  (style_blk%?0 
  643.  %110000) <> 0 
  644.  Triangular end caps on the path, check the widths..
  645.  (style_blk%?0 
  646.  %1100) 
  647. 9    cap_width% = style_blk%?2:
  648.  1/16ths of path width
  649. 9    cap_len%   = style_blk%?3:
  650.  1/16ths of path width
  651. 3    cap_width% = (cap_width% * (p_width% / 16))
  652. 3    cap_len%   = (cap_len%   * (p_width% / 16))
  653.  (style_blk%?0 
  654.  %110000) 
  655. :    cap_width2% = style_blk%?4:
  656.  1/16ths of path width
  657. :    cap_len2%   = style_blk%?5:
  658.  1/16ths of path width
  659. 5    cap_width2% = (cap_width2% * (p_width% / 16))
  660. 5    cap_len2%   = (cap_len2%   * (p_width% / 16))
  661.  cap_width2% > cap_width% 
  662.  cap_width% = cap_width2%
  663.  cap_len2%   > cap_len%   
  664.  cap_len%   = cap_len2%
  665.  PROCshell_Tracef0("DEBUG:: cap_width% = "+STR$cap_width%)
  666.  PROCshell_Tracef0("DEBUG:: cap_len%   = "+STR$cap_len%)
  667. shell_DrawPutWord(2,buffer%)               :
  668.  Object type 2 (path)
  669. shell_DrawPutWord(0,buffer%)               :
  670.  Size of object (dummy value)
  671. shell_DrawPutWord(bbox_xmin-cap_len%,buffer%)                :
  672.  Set size of bounding box xmin
  673. shell_DrawPutWord(bbox_ymin-(p_width%/2)-cap_width%,buffer%) :
  674.  Set size of bounding box ymin
  675. shell_DrawPutWord(bbox_xmax+cap_len%,buffer%)                :
  676.  Set size of bounding box xmax
  677. shell_DrawPutWord(bbox_ymax+(p_width%/2)+cap_width%,buffer%) :
  678.  Set size of bounding box ymax
  679. shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1):
  680.  Update DrawFile bounding box
  681. shell_DrawPutWord(buffer%!24,buffer%)      :
  682.  Fill colour (-1 = do not fill)
  683. shell_DrawPutWord(buffer%!20,buffer%)      :
  684.  Path colour (-1 = no outline)
  685. shell_DrawPutWord(buffer%!32,buffer%)      :
  686.  Path width
  687. shell_DrawPutWord(style_blk%!0,buffer%)    :
  688.  Style word
  689.  (style_blk%?0 
  690.  1 << 7) <> 0 
  691. shell_DrawPutWord(style_blk%!04,buffer%) :
  692.  Offset to pattern start
  693. shell_DrawPutWord(style_blk%!08,buffer%) :
  694.  Nr of elements in pattern
  695. shell_DrawPutWord(style_blk%!12,buffer%) :
  696.  Length of dash element
  697. shell_DrawPutWord(02,buffer%)              :
  698.  Absolute move
  699. shell_DrawPutWord(x0,buffer%)              :
  700.  x start
  701. shell_DrawPutWord(y0,buffer%)              :
  702.  y start
  703. shell_DrawPutWord(08,buffer%)              :
  704.  Draw to absolute position
  705. shell_DrawPutWord(x1,buffer%)              :
  706.  x finish
  707. shell_DrawPutWord(y1,buffer%)              :
  708.  y finish
  709. shell_DrawPutWord(00,buffer%)              :
  710.  End of path
  711. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  712.  Store size of object
  713. *|Stop PROCshell_DrawLine
  714. !*|Start PROCshell_DrawSetFont
  715. shell_DrawSetFont(buffer%,font$)
  716.  ft_start%,ft_end%,f_handle%,ptr%,name$,found%
  717. found%    = 
  718. f_handle% = 0
  719.  font$ = "" 
  720. -  !buffer% = 0 :
  721.  Font 0 is system font..
  722.  Search font table to find internal font handle of requested font
  723.   ft_start% = buffer%!44
  724.  ft_start% = -1 
  725.  99,"No fonts have been initialised for this drawfile"
  726. F  ft_start% += buffer% :
  727.  Now points to start of font table object
  728.  PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_start%!4))
  729. *  ft_end%    = ft_start%!4 + ft_start%
  730.    ptr%       = ft_start% + 8
  731. &    ft_handle% = ?ptr% : ptr% += 1
  732. &    name$ = 
  733. shell_GetString(ptr%)
  734. V    
  735.  PROCshell_Tracef0("DEBUG::font name found ("+STR$ft_handle%+") '"+name$+"'")
  736.     ptr% += 
  737.  name$ + 1
  738.  ptr% 
  739.  4 <> 0
  740.       ptr% +=1
  741.         
  742.  name$ = font$ 
  743. )      found% = 
  744.  : ptr% = ft_end% + 1
  745. R      
  746.  PROCshell_Tracef0("DEBUG::font name match, handle is "+STR$ft_handle%)
  747.         
  748. 0      
  749.  PROCshell_Tracef0("DEBUG::NO MATCH")
  750.         
  751.  ptr% >= ft_end%
  752.  found% 
  753.   !buffer% = ft_handle%
  754.  PROCshell_Tracef0("DEBUG::Setting font handle to "+STR$(!buffer%))
  755.  99,"Font '"+font$+"' has not been initialised"
  756.  *|Stop PROCshell_DrawSetFont
  757. "*|Start PROCshell_DrawInitFont
  758. shell_DrawInitFont(
  759.  buffer%,font_name$)
  760.  ft_start%,ptr%,def_start%
  761. shell_Fonts_FontIsAvailable(font_name$,12,12) 
  762. 6  buffer%    = 
  763. shell_HeapBlockExtend(buffer%,256)
  764. B  ptr%       = buffer% + buffer%!8   :
  765.  Next address in file..
  766.   def_start% = ptr%
  767.  buffer%!40 = -1 
  768. J    
  769.  This routine hasn't been called before, so create new font table
  770. T    buffer%!44 = buffer%!8           :
  771.  Store file offset to start of font table
  772. D    !ptr% = 0:ptr% += 4              :
  773.  Create font table object
  774. D    !ptr% = 0:ptr% += 4              :
  775.  Skip object size for now
  776. ?    buffer%!40 = 0                   :
  777.  Nr of defined fonts
  778. J  ft_start% = buffer% + buffer%!44   :
  779.  Start of font table definition
  780. @  buffer%!40 += 1                    :
  781.  Increment font count
  782. T  ?ptr% = buffer%!40                 :
  783.  Store internal font handle (starts at 1)
  784. F  $(ptr%+1) = font_name$             :
  785.  Store textual name of font
  786.   ptr% += 
  787. (font_name$) + 2
  788. G  ?(ptr% - 1) = 0                    :
  789.  Terminate name with CHR$(0)
  790.  ptr% 
  791.  4 <> 0              :
  792.  Pad with trailing spaces to a word boundary
  793.     ?ptr% = 0
  794.     ptr% += 1
  795. L  ft_start%!04   = ptr% - ft_start%  :
  796.  Update size of font table object
  797. C  buffer%!08 += ptr% - def_start%    :
  798.  Update size of DrawFile
  799.  Finally shrink heap block..
  800. H  buffer% = 
  801. shell_HeapBlockExtend(buffer%,(ptr% - ft_start%) - 256)
  802. h  void% = 
  803. shell_MessageWindow(
  804. shell_MessageOneArg("SHELLMSG31",font_name$),0,
  805. shell_GetAppName,"")
  806. !*|Stop PROCshell_DrawInitFont
  807. $*|Start PROCshell_DrawSetUnitsMM
  808. shell_DrawSetUnitsMM( buffer% )
  809. |(buffer% + 12) = 1814.1732
  810. #*|Stop PROCshell_DrawSetUnitsMM
  811. $*|Start PROCshell_DrawSetUnitsCM
  812. shell_DrawSetUnitsCM( buffer% )
  813. |(buffer% + 12) = 18141.732
  814. #*|Stop PROCshell_DrawSetUnitsCM
  815. $*|Start PROCshell_DrawSetUnitsIN
  816. shell_DrawSetUnitsIN( buffer% )
  817. |(buffer% + 12) = 46080
  818. #*|Stop PROCshell_DrawSetUnitsIN
  819. #$*|Start PROCshell_DrawSetUnitsOS
  820. shell_DrawSetUnitsOS( buffer% )
  821. |(buffer% + 12) = 256
  822. (#*|Stop PROCshell_DrawSetUnitsOS
  823. ,$*|Start PROCshell_DrawSetUnitsPT
  824. shell_DrawSetUnitsPT( buffer% )
  825. |(buffer% + 12) = 640
  826. 1#*|Stop PROCshell_DrawSetUnitsPT
  827. 5(*|Start PROCshell_DrawSetPathPattern
  828. shell_DrawSetPathPattern(buffer%,dashed%,offset,nr_el%,len)
  829.  pat_blk%,scl_fac
  830. pat_blk% = buffer%!48
  831. scl_fac  = |(buffer% + 12)
  832. :$pat_blk%?0 = pat_blk%?0 
  833.  1 << 7
  834.  dashed% = 0 
  835. <&  pat_blk%?0 = pat_blk%?0 
  836.  1 << 7
  837. >"pat_blk%!04 = offset * scl_fac
  838. pat_blk%!08 = nr_el%
  839. @"pat_blk%!12 = len    * scl_fac
  840. C'*|Stop PROCshell_DrawSetPathPattern
  841. G(*|Start PROCshell_DrawGetBoundingBox
  842. shell_DrawGetBoundingBox(buffer%,
  843.  xpos,
  844.  ypos,
  845.  width,
  846.  height,os_units%)
  847.  drawfile_start%,drawfile_size%,bbox_blk%,trans_matrix%,div%
  848. J*drawfile_start%  = buffer% + buffer%!4
  849. K,drawfile_size%   = buffer%!8 - buffer%!4
  850. L!trans_matrix%    = buffer%!52
  851. trans_matrix%!20 = 0
  852. trans_matrix%!24 = 0
  853. O)bbox_blk% = 
  854. shell_HeapBlockFetch(16)
  855.  os_units% <> 0 
  856.  div% = 256 
  857.  div% = 1
  858.  "DrawFile_BBox",0,drawfile_start%,drawfile_size%,trans_matrix%,bbox_blk%
  859. R"xpos   = (bbox_blk%!00) / div%
  860. S"ypos   = (bbox_blk%!04) / div%
  861. T0width  = (bbox_blk%!08 - bbox_blk%!00)/ div%
  862. U0height = (bbox_blk%!12 - bbox_blk%!04)/ div%
  863. shell_HeapBlockReturn(bbox_blk%)
  864. X'*|Stop PROCshell_DrawGetBoundingBox
  865. \#*|Start FNshell_DrawGetFileSize
  866. shell_DrawGetFileSize( buffer% )
  867. = buffer%!8 - buffer%!4
  868. `"*|Stop FNshell_DrawGetFileSize
  869. h$*|Start PROCshell_DrawRenderFile
  870. shell_DrawRenderFile(buffer%,x%,y%,q%,bound%)
  871.  drawsc%,draw%,drawlen%
  872.  bound%=-1 
  873.  bound% = 1 
  874.  bound% = 0
  875. drawsc%  = buffer%!52
  876. m"draw%    = buffer% + buffer%!4
  877. n$drawlen% = buffer%!8 - buffer%!4
  878. drawsc%!16 = x% * 256
  879. drawsc%!20 = y% * 256
  880.  "DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
  881. drawsc%!16 = 0
  882. drawsc%!20 = 0
  883. v#*|Stop PROCshell_DrawRenderFile
  884.  *|Start PROCshell_DrawRenderFile
  885.  DEF PROCshell_DrawRenderFile(buffer%,x%,y%,x_scl,y_scl,q%,bound%)
  886.  LOCAL drawsc%,draw%,drawlen%
  887.  IF bound%=-1 THEN bound% = 1 ELSE bound% = 0
  888.  drawsc%  = FNshell_HeapBlockFetch(24)
  889.  draw%    = buffer% + buffer%!4
  890.  drawlen% = buffer%!8 - buffer%!4
  891.  !drawsc% = INT(65536 * x_scl)
  892.  drawsc%!04 = 0
  893.  drawsc%!08 = 0
  894.  drawsc%!12 = INT(65536 * y_scl)
  895.  drawsc%!16 = x% * 256
  896.  drawsc%!20 = y% * 256
  897.  SYS "DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
  898.  PROCshell_HeapBlockReturn(drawsc%)
  899.  ENDPROC
  900.  *|Stop PROCshell_DrawRenderFile
  901. !*|Start FNshell_DrawTextCoord
  902. shell_DrawTextCoord(v%,r%,scale%) = (v% * scale% + r% +scale% / 2) / scale%
  903.  *|Stop FNshell_DrawTextCoord
  904. **|Start PROCshell_DrawSetJoinStyleNone
  905. shell_DrawSetJoinStyleNone( buffer% )
  906.  style_blk%
  907. style_blk% = buffer%!48
  908. =style_blk%?0 = style_blk%?0 
  909.  ( 1 << 0 ) :
  910.  unset bit 0
  911. =style_blk%?0 = style_blk%?0 
  912.  ( 1 << 1 ) :
  913.  unset bit 1
  914. )*|Stop PROCshell_DrawSetJoinStyleNone
  915. +*|Start PROCshell_DrawSetJoinStyleRound
  916. shell_DrawSetJoinStyleRound( buffer% )
  917.  style_blk%
  918. style_blk% = buffer%!48
  919. >style_blk%?0 = style_blk%?0 
  920.   1 << 0         :
  921.  set bit 0
  922. =style_blk%?0 = style_blk%?0 
  923.  ( 1 << 1 ) :
  924.  unset bit 1
  925. **|Stop PROCshell_DrawSetJoinStyleRound
  926. .*|Start PROCshell_DrawSetJoinStyleBevelled
  927. shell_DrawSetJoinStyleBevelled( buffer% )
  928.  style_blk%
  929. style_blk% = buffer%!48
  930. =style_blk%?0 = style_blk%?0 
  931.  ( 1 << 0 ) :
  932.  unset bit 0
  933. >style_blk%?0 = style_blk%?0  
  934.  1 << 1         :
  935.  set bit 1
  936. -*|Stop PROCshell_DrawSetJoinStyleBevelled
  937. '*|Start PROCshell_DrawSetEndCapNone
  938. shell_DrawSetEndCapNone( buffer% )
  939.  style_blk%
  940. style_blk% = buffer%!48
  941. 6style_blk%?0 = style_blk%?0  
  942.  1 << 2 :
  943.  set bit 2
  944. 6style_blk%?0 = style_blk%?0  
  945.  1 << 3 :
  946.  set bit 3
  947. 7style_blk%?0 = style_blk%?0 
  948.  1 << 2 :
  949.  unset bit 2
  950. 7style_blk%?0 = style_blk%?0 
  951.  1 << 3 :
  952.  unset bit 3
  953. &*|Stop PROCshell_DrawSetEndCapNone
  954. (*|Start PROCshell_DrawSetEndCapRound
  955. shell_DrawSetEndCapRound( buffer% )
  956.  style_blk%
  957. style_blk% = buffer%!48
  958. 6style_blk%?0 = style_blk%?0  
  959.  1 << 2 :
  960.  set bit 2
  961. 6style_blk%?0 = style_blk%?0  
  962.  1 << 3 :
  963.  set bit 3
  964. 7style_blk%?0 = style_blk%?0 
  965.  1 << 3 :
  966.  unset bit 3
  967. '*|Stop PROCshell_DrawSetEndCapRound
  968. )*|Start PROCshell_DrawSetEndCapSquare
  969. shell_DrawSetEndCapSquare( buffer% )
  970.  style_blk%
  971. style_blk% = buffer%!48
  972. 6style_blk%?0 = style_blk%?0  
  973.  1 << 2 :
  974.  set bit 2
  975. 6style_blk%?0 = style_blk%?0  
  976.  1 << 3 :
  977.  set bit 3
  978. 7style_blk%?0 = style_blk%?0 
  979.  1 << 2 :
  980.  unset bit 2
  981. (*|Stop PROCshell_DrawSetEndCapSquare
  982. +*|Start PROCshell_DrawSetEndCapTriangle
  983. shell_DrawSetEndCapTriangle(buffer%,width%,len%)
  984.  style_blk%,path_width%
  985. !path_width% = buffer%!32 / 16
  986. style_blk%  = buffer%!48
  987. %width% = width% * |(buffer% + 12)
  988. %len%   = len%   * |(buffer% + 12)
  989. 6style_blk%?0 = style_blk%?0  
  990.  1 << 2 :
  991.  set bit 2
  992. 6style_blk%?0 = style_blk%?0  
  993.  1 << 3 :
  994.  set bit 3
  995. 'style_blk%?2 = width% / path_width%
  996. 'style_blk%?3 = len%   / path_width%
  997.  PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
  998. **|Stop PROCshell_DrawSetEndCapTriangle
  999. )*|Start PROCshell_DrawSetStartCapNone
  1000. shell_DrawSetStartCapNone( buffer% )
  1001.  style_blk%
  1002. style_blk% = buffer%!48
  1003. 6style_blk%?0 = style_blk%?0  
  1004.  1 << 4 :
  1005.  set bit 4
  1006. 6style_blk%?0 = style_blk%?0  
  1007.  1 << 5 :
  1008.  set bit 5
  1009. 7style_blk%?0 = style_blk%?0 
  1010.  1 << 4 :
  1011.  unset bit 4
  1012. 7style_blk%?0 = style_blk%?0 
  1013.  1 << 5 :
  1014.  unset bit 5
  1015. (*|Stop PROCshell_DrawSetStartCapNone
  1016. **|Start PROCshell_DrawSetStartCapRound
  1017. shell_DrawSetStartCapRound( buffer% )
  1018.  style_blk%
  1019. style_blk% = buffer%!48
  1020. 6style_blk%?0 = style_blk%?0  
  1021.  1 << 4 :
  1022.  set bit 4
  1023. 6style_blk%?0 = style_blk%?0  
  1024.  1 << 5 :
  1025.  set bit 5
  1026. 7style_blk%?0 = style_blk%?0 
  1027.  1 << 5 :
  1028.  unset bit 5
  1029. )*|Stop PROCshell_DrawSetStartCapRound
  1030. +*|Start PROCshell_DrawSetStartCapSquare
  1031. shell_DrawSetStartCapSquare( buffer% )
  1032.  style_blk%
  1033. style_blk% = buffer%!48
  1034. 6style_blk%?0 = style_blk%?0  
  1035.  1 << 4 :
  1036.  set bit 4
  1037. 6style_blk%?0 = style_blk%?0  
  1038.  1 << 5 :
  1039.  set bit 5
  1040. 7style_blk%?0 = style_blk%?0 
  1041.  1 << 4 :
  1042.  unset bit 4
  1043. **|Stop PROCshell_DrawSetStartCapSquare
  1044.  -*|Start PROCshell_DrawSetStartCapTriangle
  1045. shell_DrawSetStartCapTriangle(buffer%,width%,len%)
  1046.  style_blk%,path_width%
  1047. style_blk%  = buffer%!48
  1048. $!path_width% = buffer%!32 / 16
  1049. %%width% = width% * |(buffer% + 12)
  1050. &%len%   = len%   * |(buffer% + 12)
  1051. '6style_blk%?0 = style_blk%?0  
  1052.  1 << 4 :
  1053.  set bit 4
  1054. (6style_blk%?0 = style_blk%?0  
  1055.  1 << 5 :
  1056.  set bit 5
  1057. )'style_blk%?2 = width% / path_width%
  1058. *'style_blk%?3 = len%   / path_width%
  1059.  PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
  1060. .,*|Stop PROCshell_DrawSetStartCapTriangle
  1061. 2"*|Start PROCshell_DrawSetScale
  1062. shell_DrawSetScale(buffer%,xscl,yscl)
  1063.  matrix%
  1064. matrix%    = buffer%!52
  1065. 6 matrix%!00 = 
  1066. (65536 * xscl)
  1067. 7 matrix%!12 = 
  1068. (65536 * yscl)
  1069. :!*|Stop PROCshell_DrawSetScale
  1070. >"*|Start PROCshell_DrawGetScale
  1071. shell_DrawGetScale(buffer%,
  1072.  xscl,
  1073.  yscl)
  1074.  matrix%
  1075. matrix% = buffer%!52
  1076. B xscl    = matrix%!00 / 65536
  1077. C yscl    = matrix%!12 / 65536
  1078. F!*|Stop PROCshell_DrawGetScale
  1079. J&*|Start PROCshell_DrawResizeWindow
  1080. shell_DrawResizeWindow(buffer%,wh%,lm%,bm%,rm%,tm%)
  1081.  xpos,ypos,width,height
  1082. shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
  1083. shell_WindowResize(wh%,0,- (tm% + bm% + height + ypos),width + lm% + rm%,0,0)
  1084. Q%*|Stop PROCshell_DrawResizeWindow
  1085. U'*|Start PROCshell_DrawScaleToWindow
  1086. shell_DrawScaleToWindow(buffer%,wh%,lm%,bm%,rm%,tm%,
  1087.  xscl,
  1088.  yscl)
  1089.  xpos,ypos,width,height,w_blk%,w_width%,w_height%,o_xscl,o_yscl
  1090. shell_DrawSetScale(buffer%,o_xscl,o_yscl)
  1091. shell_DrawSetScale(buffer%,1,1)
  1092. shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
  1093. ['w_blk%  = 
  1094. shell_HeapBlockFetch(36)
  1095. !w_blk% = wh%
  1096.  "Wimp_GetWindowState",,w_blk%
  1097. ^Aw_width%  = (w_blk%!12 - w_blk%!04 + w_blk%!20) - (lm% + rm%)
  1098. _Aw_height% = (w_blk%!16 - w_blk%!08 + w_blk%!24) - (tm% + bm%)
  1099. `*xscl      = (w_width%  / (width  - 0))
  1100. a*yscl      = (w_height% / (height - 0))
  1101.  PROCshell_Tracef0(">>> "+STR$w_width%)
  1102.  PROCshell_Tracef0(">>> "+STR$width)
  1103.  PROCshell_Tracef0(">>> "+STR$w_height%)
  1104.  PROCshell_Tracef0(">>> "+STR$height)
  1105.  PROCshell_Tracef0(">>> xscl "+STR$xscl)
  1106.  PROCshell_Tracef0(">>> yscl "+STR$yscl)
  1107. shell_HeapBlockReturn(w_blk%)
  1108. shell_DrawSetScale(buffer%,o_xscl,o_yscl)
  1109. l&*|Stop PROCshell_DrawScaleToWindow
  1110. p$*|Start PROCshell_DrawSpriteArea
  1111. shell_DrawSpriteArea( 
  1112.  buffer%, area_size%, 
  1113.  sprite_area% )
  1114.  first extend the drawfile buffer to hold the sprite..
  1115. tYbuffer% = 
  1116. shell_HeapBlockExtend( buffer%, area_size% + 
  1117. shell_SpritesGetHeaderSize )
  1118.  set up a sprite area within this block..
  1119. w/sprite_area% = buffer% + ( buffer%!4 ) + 48
  1120. shell_SpriteAreaInit( sprite_area%, area_size% + 
  1121. shell_SpritesGetHeaderSize )
  1122. z$buffer%!8 += ( area_size% + 24 )
  1123. ~#*|Stop PROCshell_DrawSpriteArea
  1124.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1125.  Responses to events raised by other modules..
  1126.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1127.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1128.  Private module routines
  1129.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1130. #*|Start PROCshell_DrawPutString
  1131. shell_DrawPutString(S$,
  1132.  ptr%)
  1133. $ptr% = S$
  1134. ptr% += 
  1135.   ?ptr% = 0
  1136.   ptr% += 1
  1137.  ptr% 
  1138.  4 = 0
  1139. "*|Stop PROCshell_DrawPutString
  1140. #*|Start PROCshell_DrawPutCoords
  1141. shell_DrawPutCoords(start%,lx%,by%,rx%,ty%)
  1142. start%!00 = lx%
  1143. start%!04 = by%
  1144. start%!08 = rx%
  1145. start%!12 = ty%
  1146. "*|Stop PROCshell_DrawPutCoords
  1147. !*|Start PROCshell_DrawPutWord
  1148. shell_DrawPutWord(k%,
  1149.  buffer%)
  1150.  next%
  1151. /buffer% = 
  1152. shell_HeapBlockExtend(buffer%,4)
  1153.  next% = buffer% + buffer%!08
  1154. !next% = k%
  1155. buffer%!08 += 4
  1156.  *|Stop PROCshell_DrawPutWord
  1157. **|Start PROCshell_DrawUpdateObjectBBox
  1158. shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
  1159.  x_coord < DRW_PATH_XMIN 
  1160.  DRW_PATH_XMIN = x_coord
  1161.  x_coord > DRW_PATH_XMAX 
  1162.  DRW_PATH_XMAX = x_coord
  1163.  y_coord < DRW_PATH_YMIN 
  1164.  DRW_PATH_YMIN = y_coord
  1165.  y_coord > DRW_PATH_YMAX 
  1166.  DRW_PATH_YMAX = y_coord
  1167. 7!( buffer% + DRW_PATH_START% + 08 ) = DRW_PATH_XMIN
  1168. 7!( buffer% + DRW_PATH_START% + 12 ) = DRW_PATH_YMIN
  1169. 7!( buffer% + DRW_PATH_START% + 16 ) = DRW_PATH_XMAX
  1170. 7!( buffer% + DRW_PATH_START% + 20 ) = DRW_PATH_YMAX
  1171. )*|Stop PROCshell_DrawUpdateObjectBBox
  1172. &*|Start PROCshell_DrawUpdateBounds
  1173. shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1)
  1174.  bb_start%
  1175. #bb_start% = buffer% + buffer%!4
  1176.  x0 > x1 
  1177.  x0,x1
  1178.  y0 > y1 
  1179.  y0,y1
  1180.  (bb_start% + 32) = 0 
  1181.  !(bb_start% + 36) = 0 
  1182.   !(bb_start% + 24) = x0
  1183.   !(bb_start% + 28) = y0
  1184.   !(bb_start% + 32) = x1
  1185.   !(bb_start% + 36) = y1
  1186.  x0 < !(bb_start% + 24) 
  1187.  !(bb_start% + 24) = x0
  1188.  y0 < !(bb_start% + 28) 
  1189.  !(bb_start% + 28) = y0
  1190.  x1 > !(bb_start% + 32) 
  1191.  !(bb_start% + 32) = x1
  1192.  y1 > !(bb_start% + 36) 
  1193.  !(bb_start% + 36) = y1
  1194.  buffer%!28 > 0 
  1195. shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
  1196. %*|Stop PROCshell_DrawUpdateBounds
  1197. +*|Start PROCshell_DrawUpdateGroupBounds
  1198. shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
  1199.  bb_start%
  1200. $bb_start% = buffer% + buffer%!28
  1201.  PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
  1202.  PROCshell_Tracef0("DEBUG::current x0 = "+STR$(!(bb_start% + 08)))
  1203.  !(bb_start% + 08) = -1 
  1204.   !(bb_start% + 08) = x0
  1205.  x0 < !(bb_start% + 08) 
  1206.  !(bb_start% + 08) = x0
  1207.  !(bb_start% + 12) = -1 
  1208.   !(bb_start% + 12) = y0
  1209.  y0 < !(bb_start% + 12) 
  1210.  !(bb_start% + 12) = y0
  1211.  x1 > !(bb_start% + 16) 
  1212.  !(bb_start% + 16) = x1
  1213.  y1 > !(bb_start% + 20) 
  1214.  !(bb_start% + 20) = y1
  1215.  PROCshell_Tracef0("DEBUG::x0 = "+STR$x0)
  1216.  PROCshell_Tracef0("DEBUG::y0 = "+STR$y0)
  1217.  PROCshell_Tracef0("DEBUG::x1 = "+STR$x1)
  1218.  PROCshell_Tracef0("DEBUG::y1 = "+STR$y1)
  1219.  PROCshell_Tracef0("")
  1220.  PROCshell_Tracef0("DEBUG::x0 = "+STR$(!(bb_start%+8)))
  1221. **|Stop PROCshell_DrawUpdateGroupBounds
  1222.  *|Start FNshell_DrawFontName
  1223. shell_DrawFontName(ptr%,font%)
  1224.  ft_table%,ft_end%,df_start%,font$,p%,ft_handle%,found%
  1225.  ptr%!44 = -1 
  1226.  99,"No fonts have been initialised for this drawfile"
  1227. df_start%  = ptr% + ptr%!4
  1228. ft_table%  = ptr%!44 + ptr%
  1229.  PROCshell_Tracef0("DEBUG::ft_table% = &"+STR$~ft_table%)
  1230.  PROCshell_Tracef0("DEBUG::df_start% = &"+STR$~df_start%)
  1231.  font% = 0 
  1232.   font$ = "System Font"
  1233.  PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_table%!4))
  1234. *  ft_end%    = ft_table%!4 + ft_table%
  1235.    p%         = ft_table% + 8
  1236. "    ft_handle% = ?p% : p% += 1
  1237. $    font$ = 
  1238. shell_GetString(p%)
  1239.     p%   += 
  1240.  font$ + 1
  1241.  4 <> 0
  1242.       p% +=1
  1243.         
  1244.  ft_handle% = font% 
  1245. '      found% = 
  1246.  : p% = ft_end% + 1
  1247.         
  1248.   p% >= ft_end%
  1249.  found% = 0 
  1250.  99,"Font not found in font table"
  1251. = font$
  1252. *|Stop FNshell_DrawFontName
  1253. ##*|Start PROCshell_DrawTextSpace
  1254. shell_DrawTextSpace(ptr%,text$,font%,ptsize,pthigh,
  1255.  lx%,
  1256.  by%,
  1257.  rx%,
  1258.  ty%)
  1259.  handle%,xscale%,yscale%,r1%,r2%,r3%,r4%
  1260.  font% > 0 
  1261.  "Font_FindFont",,
  1262. shell_DrawFontName(ptr%,font%),ptsize * 16, pthigh * 16 
  1263.  handle%
  1264.  "Font_SetFont",handle%
  1265.  "Font_StringBBox",,text$ 
  1266.  ,r1%,r2%,r3%,r4%
  1267.  "Font_ReadScaleFactor" 
  1268.  ,xscale%,yscale%
  1269.  "Font_LoseFont",handle%
  1270. ,1  ty% = 
  1271. shell_DrawTextCoord(by%,r4%,yscale%)
  1272. -1  rx% = 
  1273. shell_DrawTextCoord(lx%,r3%,xscale%)
  1274. .1  by% = 
  1275. shell_DrawTextCoord(by%,r2%,yscale%)
  1276. /1  lx% = 
  1277. shell_DrawTextCoord(lx%,r1%,xscale%)
  1278. 1)  rx% = lx% + ptsize * 2.5 * 
  1279. (text$)
  1280.   ty% = by% + pthigh * 2.5
  1281. 6"*|Stop PROCshell_DrawTextSpace
  1282.